import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# 加载数据到DataFrame中
df = pd.read_csv('diabetes_data.csv')

# 设置seaborn的样式
sns.set_style("whitegrid")

# 连续变量的柱状图
continuous_vars = ['weight', 'height', 'blood_glucose', 'physical_activity', 'sleep_hours']
colors = ['#FF6666', '#FFCC66', '#FF9366', '#FFCC99', '#C2C2C9']  # 为每个变量指定不同的颜色

for var, color in zip(continuous_vars, colors):
    plt.figure(figsize=(10, 6))
    sns.histplot(data=df, x=var, color=color, kde=True)  # 使用核密度估计
    plt.title(f'Distribution of {var}')
    plt.xlabel(var)
    plt.ylabel('Density')
    plt.show()

# 分类变量的饼图
categorical_vars = ['diet', 'medication_adherence', 'stress_level', 'hydration_level']
categorical_colors = ['#66FF66', '#CCFF66', '#66CCFF99', '#C2C2C9']  # 为每个分类变量指定不同的颜色

for var, color in zip(categorical_vars, categorical_colors):
    plt.figure(figsize=(8, 8))
    sns.countplot(y=df[var], palette=[color])  # 使用countplot代替pie
    plt.title(f'Distribution of {var}')
    plt.xlabel('Count')
    plt.ylabel(var)
    plt.show()